package com.distortiongames.level27.generation
{
	import com.distortiongames.level27.generation.random.*;
	
	/**
	 * ...
	 * @author Jefferson Wagner
	 */
	public class Parameters
	{
		public var spawnCorridor:ChanceWithMinimum, age:ChanceWithMinimum, spawnBranch:ChanceWithMinimum;
		public var turnChance:Chance, forkChance:Chance;
		public var elementChance:ElementalChance;
		public var childAgeModifier:Number, childCorridorDecrement:Number;
		
		public function Parameters()
		{
			spawnCorridor = new ChanceWithMinimum();
			age = new ChanceWithMinimum();
			spawnBranch = new ChanceWithMinimum();
			turnChance = new Chance();
			forkChance = new Chance();
			childAgeModifier = 0;
			childCorridorDecrement = 0;
			elementChance = new ElementalChance(0);
		}
		
		public function copy():Parameters
		{
			var newParams:Parameters = new Parameters();
			newParams.setAge(age.copyMinimum());
			newParams.setSpawnBranch(spawnBranch.copyMinimum());
			newParams.setSpawnCorridor(spawnCorridor.copyMinimum());
			newParams.setTurnChance(turnChance.copy());
			newParams.setForkChance(forkChance.copy());
			newParams.setChildAgeModifier(childAgeModifier);
			newParams.setChildCorridorDecrement(childCorridorDecrement);
			newParams.setElementChance(elementChance);
			return newParams;
		}
		
		public function makeChild():Parameters
		{
			var childParams:Parameters = this.copy();
			var childAge:ChanceWithMinimum = childParams.age;
			childAge.setMinimumRolls(childAge.getMinimumRolls() / childAgeModifier);
			var childCorridor:ChanceWithMinimum = childParams.spawnCorridor;
			childCorridor.setMinimumRolls(childCorridor.getMinimumRolls() - childCorridorDecrement);
			return childParams;
		}
		
		public function setSpawnCorridor(chance:ChanceWithMinimum):void
		{
			spawnCorridor = chance;
		}
		
		public function setAge(chance:ChanceWithMinimum):void
		{
			age = chance;
		}
		
		public function setSpawnBranch(chance:ChanceWithMinimum):void
		{
			spawnBranch = chance;
		}
		
		public function setTurnChance(chance:Chance):void
		{
			turnChance = chance;
		}
		
		public function setForkChance(chance:Chance):void
		{
			forkChance = chance;
		}
		
		public function setChildAgeModifier(value:Number) : void
		{
			childAgeModifier = value;
		}
		
		public function setChildCorridorDecrement(value:Number) : void
		{
			childCorridorDecrement = value;
		}
		
		public function setElementChance(chance:ElementalChance):void 
		{
			elementChance = chance;
		}
	}

}